package aps.module_Core;

//import net.minecraft.src.*;
//Vanilla Minecraft
import net.minecraft.src.Block;
import net.minecraft.src.GuiContainer;
import net.minecraft.src.InventoryPlayer;
import net.minecraft.src.Item;
import net.minecraft.src.GuiScreen;

//APS
import aps.GuiAPSSlider;
import aps.BuildcraftAPS;

//forge
//import net.minecraftforge.ITextureProvider;
import net.minecraftforge.client.MinecraftForgeClient;

//Java
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;

public class GuiControlPanel extends GuiScreen
{	
	ItemAPSControlPanel controlPanel;
	
	enum Mode {Param, Meter}
	Mode PanelMode;
	
	GuiAPSSlider InSlider;
	GuiAPSSlider OutSlider;
	
	String guiFile = BuildcraftAPS.imageFilesRoot + "EnergyStoreGUI.png";
	
	public GuiControlPanel(ItemAPSControlPanel panel)
	{
		super();
		controlPanel = panel;
	}
	
	@Override
	public void initGui()
	{
		super.initGui();
		
		//controlList.add(InSlider);
	}
	
	@Override
	public void handleMouseInput()
    {
		boolean isShift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
		int wheel = org.lwjgl.input.Mouse.getDWheel() / 120;
		if (wheel == 0){
			super.handleMouseInput();
			return;
		}
		if(isShift)
		{
			if (wheel > 0)
				nextMode();
			else
				prevMode();
		}
		else
		{
			//switch(PanelMode)
			//{
				
			//}
		}
        super.handleMouseInput();
    }
	
	void nextMode()
	{
		int nm = PanelMode.ordinal() + 1;
		if (nm >= Mode.values().length)
			nm -= Mode.values().length;
		PanelMode = Mode.values()[nm];
	}
	
	void prevMode()
	{
		int pm = PanelMode.ordinal() + 1;
		if (pm < 0)
			pm += Mode.values().length;
		PanelMode = Mode.values()[pm];
	}
	
	protected void drawGuiContainerForegroundLayer()
    {
        //fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
    }
	
	protected void drawGuiContainerBackgroundLayer(float f, int i , int j)
    {
        //int guiTex = mc.renderEngine.getTexture(guiFile);
        //GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        //int topLeftX = (width - xSize) / 2;
        //int topLeftY = (height - ySize) / 2;
        //mc.renderEngine.bindTexture(guiTex);
        //drawTexturedModalRect(topLeftX, topLeftY, 0, 0, xSize, ySize);
    }
	
	private void displayTempGauge(int TopLeftX, int TopLeftY, int GaugeTopLeftX, int GaugeTopLeftY, int BarHeight)
	{
		MinecraftForgeClient.preloadTexture(guiFile);
		
		int start = 0;

		while (true)
		{
			int x = 0;

			if (BarHeight > 8) {
				x = 8;
				BarHeight -= 8;
			} else {
				x = BarHeight;
				BarHeight = 0;
			}

			drawTexturedModalRect(TopLeftX + GaugeTopLeftX, TopLeftY + GaugeTopLeftY + 58 - x - start, 176, 8 + (8 - x), 8, x); //The 58 is the gauge height
			start = start + 8;

			if (x == 0 || BarHeight == 0) {
				break;
			}
		} //This while draws the repeating gauge graphic.
    }
	
	private void displayPowerGauge(int TopLeftX, int TopLeftY, int GaugeTopLeftX, int GaugeTopLeftY, int BarWidth)
	{
		MinecraftForgeClient.preloadTexture(guiFile);
		
		int start = 0;

		while (true)
		{
			int x = 0;

			if (BarWidth > 8) {
				x = 8;
				BarWidth -= 8;
			} else {
				x = BarWidth;
				BarWidth = 0;
			}

			drawTexturedModalRect(TopLeftX + GaugeTopLeftX + start, TopLeftY + GaugeTopLeftY, 176, 8, x, 8); //The 58 is the gauge height
			start = start + 8;

			if (x == 0 || BarWidth == 0) {
				break;
			}
		} //This while draws the repeating gauge graphic.
    }
}